package com.jbjr.tianchi.controller;

import com.jbjr.tianchi.Parments.QueryEs;
import com.jbjr.tianchi.service.QueryEsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author：zgh
 * @DATE: 2018/7/31 15:06
 * @version: 0.0.1
 * @Description: es 公共查询方法
 */
@RestController
public class QueryEsController {

    @Autowired
    private QueryEsService queryEsService;

    @RequestMapping(value = "/p/queryEs" ,method = RequestMethod.POST)
    public Map<String, Object> queryEs(@RequestBody QueryEs param){
        Map<String, Object> resMap = new HashMap<>();
        if(StringUtils.isEmpty(param.getIndex())){
            resMap.put("status","201");
            resMap.put("message","索引名不能为空");
            return resMap;
        }
        if(StringUtils.isEmpty(param.getType())){
            resMap.put("status","201");
            resMap.put("message","类型不能为空");
            return resMap;
        }

        return queryEsService.queryEs(param);
    }







}
